#include <unistd.h>

#include <hidl/HidlTransportSupport.h>
#include <log/log.h>
#include <utils/Errors.h>
#include <utils/StrongPointer.h>

#include "EcarxAudioControl.h"


// libhidl:
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;

// Generated HIDL files
using vendor::ecarx::xma::audiocontrol::V1_0::IEcarxAudioControl;

// The namespace in which all our implementation code lives
using namespace vendor::ecarx::xma::audiocontrol::V1_0::impl;
//using namespace vendor::ecarx::xma::audiocontrol::V1_0;
using namespace android;


// Main service entry point
int main() {
    // Create an instance of our service class
    android::sp<IEcarxAudioControl> service = new EcarxAudioControl();
    configureRpcThreadpool(1, true /*callerWillJoin*/);

    if (service->registerAsService() != OK) {
        ALOGE("registerAsService failed");
        return 1;
    }

    // Join (forever) the thread pool we created for the service above
    joinRpcThreadpool();

    // We don't ever actually expect to return, so return an error if we do get here
    return 2;
}